﻿CREATE PROCEDURE [dbo].[UpdateMarkDetail]
	@Mark uniqueidentifier,
	@MarkDetailId uniqueidentifier,
	@Name nvarchar(50),
	@Value nvarchar(max),
	@DetailType int,
    @IsDeleted bit,
    @LastChanged datetime,
	@LastChangedBy uniqueidentifier,

	@TimeStamp timestamp,
	@newTimeStamp timestamp output

AS

	UPDATE MarkDetail

	SET 
	 
	 Name = @Name,
	 Value = @Value,
	 DetailType = @DetailType,
	 IsDeleted = @IsDeleted, 
	 LastChanged = @LastChanged,
 	 LastChangedBy = @LastChangedBy

	WHERE MarkDetailId = @MarkDetailId AND [TimeStamp]=@TimeStamp

  IF @@ROWCOUNT = 0

    RAISERROR('Row has been edited by another user', 16, 1)            	


	SELECT @newTimeStamp = [TimeStamp]

	FROM MarkDetail

	WHERE MarkDetailId = @MarkDetailId

RETURN 0